--
-- Author: yawei.zhu
-- Date: 2018-08-25 13:35:12
--
-- PvpChampionBookView
--

local PvpChampionBookRender = import(".renders.PvpChampionBookRender")

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ViewBase)

ClassRef.VIEW_ROOT_RES = Res.PvpChampionBookScene

local globalParNames = {"mondayReward", "tuesdayReward", "wednesdayReward", "thursdayReward", "fridayReward", "saturdayReward", "sundayReward"}

function ClassRef:init()
	self._ui.Button_close:addClickEventListener(function()
		executeFunc(self._onCloseView, self)
	end)

	local title = self._ui["Panel/Panel_right/tlt"]
	local desc = self._ui["Panel/Panel_right/tips"]
	title:setString( L("champion_award1") )
	desc:setString( L("champion_award2") )
end

function ClassRef:updateView(day)
	self._day = day

	local txtTitle = self._ui["Panel/Panel_left/tlt"]
	local txtDesc = self._ui["Panel/Panel_left/Text"]
	local image = self._ui["Panel/Panel_left/Image"]

	local throneConfig = GD:queryThroneByDay(day)
	txtTitle:setString( L(throneConfig.name) )
	image:loadTexture(Res.ThroneBgPath .. throneConfig.picture2 .. ".png")
	txtDesc:setString( L(throneConfig.introduceDes) )
 
	self:updateRightList()
end

function ClassRef:updateRightList()
	local list = self._ui["Panel/Panel_right/ListView"]
	list:removeAllChildren()

	local data = GD:getThroneStrPar( globalParNames[self._day] )
	local datas = string.split(data, ";")
	-- dump(datas)

	local length = #datas
	-- dump(length)
	for i = 1, length do
		local render = PvpChampionBookRender.create()
		render:setData(datas[i])
		list:pushBackCustomItem(render)
	end
	list:refreshView() 

end

return ClassRef
